<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="__STATIC__/bootstrap-table/js/dropdown.js"></script>
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap.css">
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">数据管理</a>
        <a href="#">教学数据</a>
        <a href="#">上课记录</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="layui-row">
    <form class="layui-form layui-col-md12 x-so" onsubmit="return false">
        <div class="layui-input-inline">
            <select name="project" id="project">
                <option value="">类型名称</option>
                {foreach $project as $value}
                    <option value="{$value.id}">{$value.sport_name}</option>
                {/foreach}
            </select>
        </div>
        <div class="layui-input-inline">
            <select name="test" id="test">
                <option value="">测试名称</option>
                {foreach $testInfo as $value}
                    <option value="{$value.id}">{$value.test_name}</option>
                {/foreach}
            </select>
        </div>
        <button class="layui-btn"  id="search"><i class="layui-icon">&#xe615;</i></button>
    </form>
</div>
<table id="record">

</table>
</body>
<script>
    $('#record').bootstrapTable({
        //获取行号
        language: 'zh-CN',
        todayHighlight: true,
        striped: true,//设置为 true 会有隔行变色效果
        method: 'post',//服务器数据的请求方式 'get' or 'post'
        url: "{:url('/course/getClassRecordInfo')}",//服务器数据的加载地址
        toolbar:'#toolbar',//
        searchOnEnterKey:true,
        sortName:'ID',//排序字段
        sortOrder : 'desc',//降序
        sidePagination: "server",   //分页方式：client客户端分页，server服务端分页（*）
        pagination: 'false',//设置为 true 会在表格底部显示分页条
        clickToSelect:'true',//设置true 将在点击行时，自动选择rediobox 和 checkbox
        singleSelect:'true',//设置True 将禁止多选
        pageSize: '30',//如果设置了分页，页面数据条数
        pageList:[30,60,90,100],
        smartDisplay:false,
        //得到查询的参数
        queryParams : function (params) {
            //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            var temp = {
                rows: params.limit,                         //页面大小
                page: (params.offset / params.limit) + 1,   //页码
                sort: params.sort,      //排序列名
                sortOrder: params.order,//排位命令（desc，asc）
                sportId:$("#project option:selected").val(),
                testId:$("#test option:selected").val(),
                teacherId:{$teacherId},
                start:$("#start").val(),
                end:$("#end").val()
            };
            return temp;
        },
        columns: [
//                {title:'请选择',align:'center',checkbox : true},
            {field: 'id', title: 'ID', align:'center'},
            {title: '教师姓名', align:'center',formatter:teacher},
            {title: '学生姓名', align:'center',formatter:student},
            {title: '测试类型', align:'center',formatter:getTestInfo},
            {title: '项目名称', align:'center',formatter:sport},
            {field: 'resting',title: '静态心率', align:'center'},
            {field: 'dynamic',title: '动态心率', align:'center'},
            {field: 'early',title: '预警值', align:'center'},
            {field: 'create_time',title: '测试时间', align:'center'}
        ]
    });
    //教师信息
    function teacher(val,rows){
        if(rows.teacher){
            return rows.teacher.teacher_name;
        }
    }
    //学生信息
    function student(val,rows){
        if(rows.student){
            return rows.student.stu_name;
        }
    }
    //测试类型
    function getTestInfo(val,rows){
        if(rows.get_test_info){
            return rows.get_test_info.test_name
        }
    }
    //项目名称
    function sport(val,rows){
        if(rows.sport){
            return rows.sport.sport_name;
        }
    }
    //检索
    $("#search").click(function(){
        $("#record").bootstrapTable(('refresh'));
    });
</script>
</html>